package pkg16b_eca.data.validate;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author KHTGRFA3C6IGU
 */
public class DateTime {
    /**
     * Return the date for today.
     * @return format: yyyy-MM-dd
     */
    public static String getDate() {
        return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
    }
    
    /**
     * Return the time for today.
     * @return format: hh:mm:ss
     */
    public static String getTime() {
        return new SimpleDateFormat("hh:mm:ss").format(new Date());
    }
    
    /**
     * Return the date and time for today.
     * @return format: yyyy-MM-dd : hh:mm:ss
     */
    public static String getDateTime() {
        return new SimpleDateFormat("yyyy-MM-dd : hh:mm:ss").format(new Date());
    }
    
    /**
     * Get the name of today.
     * @return the name of today's day.
     */
    public static String getDay() {
        return new SimpleDateFormat("E").format(new Date());
    }
    
    /**
     * Format a date and/or time. Enter the formatting you want to use and the date you want to format.
     *  G	Era designator	AD,    
        y	Year in four digits	2001,    
        M	Month in year	July or 07,    
        d	Day in month	10,    
        h	Hour in A.M./P.M. (1~12)	12,    
        H	Hour in day (0~23)	22,    
        m	Minute in hour	30,    
        s	Second in minute	55,    
        S	Millisecond	234,    
        E	Day in week	Tuesday,    
        D	Day in year	360,    
        F	Day of week in month	2 (second Wed. in July),    
        w	Week in year	40,    
        W	Week in month	1,    
        a	A.M./P.M. marker	PM,    
        k	Hour in day (1~24)	24,    
        K	Hour in A.M./P.M. (0~11)	10,    
        z	Time zone	Eastern Standard Time,    
        '	Escape for text	Delimiter,    
     * @param date date to format.
     * @param format the formatting to be done.
     * @return formatted date.
     */
    public static String format(String format, Date date) {
        return new SimpleDateFormat(format).format(date);
    }
    
    /**
     * Format a date of yours, this format will return using the current time and date.
     *  G	Era designator	AD,    
        y	Year in four digits	2001,    
        M	Month in year	July or 07,    
        d	Day in month	10,    
        h	Hour in A.M./P.M. (1~12)	12,    
        H	Hour in day (0~23)	22,    
        m	Minute in hour	30,    
        s	Second in minute	55,    
        S	Millisecond	234,    
        E	Day in week	Tuesday,    
        D	Day in year	360,    
        F	Day of week in month	2 (second Wed. in July),    
        w	Week in year	40,    
        W	Week in month	1,    
        a	A.M./P.M. marker	PM,    
        k	Hour in day (1~24)	24,    
        K	Hour in A.M./P.M. (0~11)	10,    
        z	Time zone	Eastern Standard Time,    
        '	Escape for text	Delimiter,    
     * @param date date to format.
     * @param format the formatting to be done.
     * @return formatted date.
     */
    public static String format(String format) {
        return new SimpleDateFormat(format).format(new Date());
    }
    
    /**
     * Return the current milliseconds from the Date declaration.
     * @return format: S
     */
    public static String getCurrentMilliseconds() {
        return new SimpleDateFormat("S").format(new Date());
    }
    
    /**
     * @return the computer's nano time.
     */
    public static long getNanoTime() {
        return System.nanoTime();
    }
    
    /**
     * Calculate the difference between times. Example: getDifference(getNanoTime(), getNanoTime()+1);
     * @param startTime the start time value.
     * @param endTime the end time value.
     * @return the difference between two values.
     */
    public static double getDifference(long startTime, long endTime) {
        return (startTime - endTime)/1e6;
    }
}
